/*****************************************************************************
Copyright 2006 Kervin L. Pierre
    EMAIL: otlkcon@adevsoft.com

This file is part of Otlkcon.

Otlkcon is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

Otlkcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lesser GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License
along with Otlkcon; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*******************************************************************************/

#pragma once

#define OTLKCON_LOG   1

// 'Release' and 'Debug' differ on these
#define OTLKCON_DEBUGBREAK
#define OTLKCON_DEFAULT_DEBUGLEVEL   0

// comment this if your system has the _scprintf function.
#define OTLKCON_PROVIDE_SCPRINTF 1

#ifdef OTLKCON_DEBUG
    /* uncomment this if you want a permanent breakpoint at DLL entry points. */
    #define OTLKCON_BREAK_AT_SERVICEENTRY 1 

    /* uncomment this if you want to run O_ITable through a testing routine */
    #define OTLKCON_TEST_O_ITABLE 1

    /* uncomment this to start with a fresh file each time */
//    #define OTLKCON_DELETE_MSTORE_DB    1
    #define OTLKCON_DELETE_PAUSE        500

    #undef  OTLKCON_DEBUGBREAK
    #define OTLKCON_DEBUGBREAK   DebugBreak();

    #undef  OTLKCON_DEFAULT_DEBUGLEVEL
    #define OTLKCON_DEFAULT_DEBUGLEVEL   -1

    #undef  OTLKCON_SQLITE_TRACE
    #define OTLKCON_SQLITE_TRACE         1

    // Should we use an in-memory database?
    //#define OTLKCON_USE_MEM_DB                      1
    #define OTLKCON_DEBUG_MEM_DB                    1
    #define OTLKCON_DEBUG_MEM_DB_FILENAME           "C:\\otlkcon_memdb.ocdb"
#endif

#ifdef OTLKCON_LOG
#define OTLKCON_LOG_DEFAULT_FILE                L"C:\\otlkcon.log"
    #define OTLKCON_LOG_MSG_MAX_LEN             65536
    
    /* Due to the use of "NULL Dacl" this should only be done */
    /* in debug builds */
    #define OTLKCON_LOG_SM_SUPPORT_ENABLED      1
    
    /* Set if you'd like the OTLKCON_LOG_TARGET_ALL define to */
    /* cause logging to shared memory. This is done to allow */
    /* an easy way of turning of general logging to SM without */
    /* turning off all logging to SM */
    #define OTLKCON_LOG_IMPLICIT_PRINTF_TO_SM   0

    #define OTLKCON_LOG_MSVC_DEBUGGER_ENABLED   1
#endif

#define OTLKCON_LOG_LEVEL_ALL           -1
#define OTLKCON_LOG_LEVEL_ERROR         1
#define OTLKCON_LOG_LEVEL_WARNING       2
#define OTLKCON_LOG_LEVEL_INFO          4
#define OTLKCON_LOG_LEVEL_SPECIAL_1     8
#define OTLKCON_LOG_LEVEL_SPECIAL_2     16
#define OTLKCON_LOG_LEVEL_SPECIAL_3     32
#define OTLKCON_LOG_LEVEL_DEFAULT       (OTLKCON_LOG_LEVEL_INFO|OTLKCON_LOG_LEVEL_WARNING|OTLKCON_LOG_LEVEL_ERROR)

#define OTLKCON_DEFAULT_FILE_EXT        L"ocdb"

#define OTLKCON_REG_KEY     L"Software\\Open Connector Groupware"
#define OTLKCON_REG_KEY_A   "Software\\Open Connector Groupware"

#define OTLKCON_REG_VALUE_MAX_LEN 255
#define OTLKCON_REG_BACKENDKEY "\\backends"

#define OTLKCON_BACKEND_DESC_MAX_LEN 255
#define OTLKCON_QUERY_MAX_LEN        1024

#define OTLKCON_SHORTTERM_ENTRYID_TYPE 1
#define OTLKCON_LONGTERM_ENTRYID_TYPE 2

#define OTLKCON_ALWAYS_DOWNLOAD_APPTS       0

#define OTLKCON_ISTREAM_MEMORY_SIZE 1048576

#define OTLKCON_GETLASTERROR_MSG_SIZE            256
#define OTLKCON_GETLASTERROR_FUNCTION_NAME_SIZE  128

#define OTLKCON_IPROP_TABLE_PROPTAG_COL     1
#define OTLKCON_IPROP_TABLE_DATA_COL        5
#define OTLKCON_ITABLE_TABLE_PROPTAG_COL    3
#define OTLKCON_ITABLE_TABLE_DATA_COL       6

#define OTLKCON_ITABLE_BOOKMARK_STATUS_OK          0
#define OTLKCON_ITABLE_BOOKMARK_STATUS_INVALID     1
#define OTLKCON_ITABLE_BOOKMARK_STATUS_DELETED     2

#define OTLKCON_ITABLE_ROW_CURRENT_COLUMNSET       0
#define OTLKCON_ITABLE_ROW_ORIGINAL_COLUMNSET      -1
#define OTLKCON_ITABLE_ROW_SORT_ORDER              -2

// That the goal anyway...
#define OTLKCON_ITABLE_ROW_COUNT_MAX    500000

// Should the debug XML include a root?
#define OTLKCON_DUMP_XML_INCLUDE_ROOT   1

#define OTLKCON_MSTORE_DLL_NAME L"mstore32.dll"

// Should we build the transport provider ?
#define OTLKCON_XP          1

#define OTLKCON_AB          1

// Turn on CalDAV support for the transport provider
#define OTLKCON_XP_CALDAV   1

// Turn on File support for the transport provider
#define OTLKCON_XP_FILE     1

#define OTLKCON_XP_CALDAV_SERVER_RESPONSE_PERIOD   500

// Account types
#define OTLKCON_ACCOUNT_TYPE_UNDEFINED      0
#define OTLKCON_ACCOUNT_TYPE_CALDAV         1
#define OTLKCON_ACCOUNT_TYPE_FILE           2

#define OTLKCON_ACCOUNT_DEFAULT_ID          L"No Name Account "

#define OTLKCON_ACCOUNT_TYPE_DESC_UNDEFINED     L"<none>"
#define OTLKCON_ACCOUNT_TYPE_DESC_UNDEFINED_A   "<none>"
#define OTLKCON_ACCOUNT_TYPE_DESC_CALDAV        L"CalDAV"
#define OTLKCON_ACCOUNT_TYPE_DESC_CALDAV_A      "CalDAV"
#define OTLKCON_ACCOUNT_TYPE_DESC_FILE          L"File"
#define OTLKCON_ACCOUNT_TYPE_DESC_FILE_A        "File"

// Maximum number of accounts
#define OTLKCON_ACCOUNT_MAX             4

// Max string lengths from GUI
#define OTLKCON_ACCOUNT_STRING_MAX      255

#define OTLKCON_DEFAULT_ACCOUNT_NAME        L"Default User Name"
#define OTLKCON_DEFAULT_ACCOUNT_EMAILADDR   L"default.user@example.com"

// Display names
#define OTLKCON_STORE_DISPLAY_NAME_A    "Open Connector"
#define OTLKCON_XP_DISPLAY_NAME_A       "Open Connector"

// Message service address type
#define OTLKCON_ADDRESS_TYPE            "OpenConnectorAddressType"

// Generic action bitmask for various functions
#define OTLKCON_ACTION_NONE     0
#define OTLKCON_ACTION_ADD      1
#define OTLKCON_ACTION_DEL      2
#define OTLKCON_ACTION_MOD      4

#define OTLKCON_PT_UNSPECIFIED_PROPTAG_STR " (propTag & 4294901760) "
#define OTLKCON_REGULAR_PROPTAG_STR        " propTag "

#define OTLKCON_MIN_DATE_STR    L"16010101T000000Z"
#define OTLKCON_MAX_DATE_STR    L"45000831T235959Z"

#define OTLKCON_ICAL_PRODID     "-//OpenConnector.Org//Outlook Extension//EN"

// Singles that a calendar component struct is flat
#define OTLKCON_CALENDAR_COMPONENT_STRUCT_FLAT_TYPE 1

// Event thread window class name
#define OTLKCON_EVENT_WINDOW_CLASSNAME  "OpenConnectorEventWindow"

#define OTLKCON_EVENT_SYNC_APPOINTMENTS             1

// Synch appointments in a calendar
#define OTLKCON_EVENT_SYNC_APPOINTMENT_COMPS        2

// Delete appointments by name
#define OTLKCON_EVENT_DEL_APPOINTMENTS              4

// Request the names of all appointments in a calendar
#define OTLKCON_EVENT_APPOINTMENT_NAME_REQ          8

// The names of all appointments in a calendar
#define OTLKCON_EVENT_APPOINTMENT_NAME_RES          16

// The configuration has changed.  Reload.
#define OTLKCON_EVENT_RELOAD_CONFIG                 32

// The object has loaded.  Sent to notify potentially
// interested listeners of that fact.
#define OTLKCON_EVENT_LOAD_NOTIFY                   64

// Ask for an objects ID
#define OTLKCON_EVENT_GET_ID                        128

// Ask for an objects ID
#define OTLKCON_EVENT_GET_ID_RES                    256

// Upload iCal message
#define OTLKCON_EVENT_UPLOAD_ICAL                   512

// Upload iCal message
#define OTLKCON_EVENT_UPLOAD_ICAL_RES               1024

// Used as a master password when none has been set.
// This really means no password.
#define OTLKCON_PASSWORD_DEFAULT         "<*_><<"

#define OTLKCON_EVENT_TIMER_RES 1000

// When query loops are unrolled, there is the danger
// of overflowing the query string buffer used by format
// unless lots
#define OTLKCON_SQL_PARAMS_TO_QUERY                 16
//////////////////////////////////////////////////////////////////////
//// PROPERTIES 
//// 6600 67FF Provider-defined internal non-transmittable property 
//////////////////////////////////////////////////////////////////////

//Keeps track of attachment numbers in the IMessage object.
#define PR_OTLKCON_IMESSAGE_ATTACH_NUM      PROP_TAG(PT_LONG,    0x6601)

//Set to 'true' if the transport provider is allowed to run against this
//message store object.
#define PR_OTLKCON_XP_ENABLED               PROP_TAG(PT_BOOLEAN, 0x6602)

//Set to 'true' if the object has been initialized and is valid.
#define PR_OTLKCON_VALID                    PROP_TAG(PT_BOOLEAN, 0x6603)

//Account 1
#define PR_OTLKCON_ACCOUNT_ID_1             PROP_TAG(PT_STRING8, 0x6604)
#define PR_OTLKCON_ACCOUNT_TYPE_1           PROP_TAG(PT_LONG,    0x6605)
#define PR_OTLKCON_ACCOUNT_NAME_1           PROP_TAG(PT_STRING8, 0x6606)
#define PR_OTLKCON_ACCOUNT_DEFAULT_1        PROP_TAG(PT_BOOLEAN, 0x6607)
#define PR_OTLKCON_ACCOUNT_ENABLE_1         PROP_TAG(PT_BOOLEAN, 0x6608)

//Account 2
#define PR_OTLKCON_ACCOUNT_ID_2             PROP_TAG(PT_STRING8, 0x6609)
#define PR_OTLKCON_ACCOUNT_TYPE_2           PROP_TAG(PT_LONG,    0x660A)
#define PR_OTLKCON_ACCOUNT_NAME_2           PROP_TAG(PT_STRING8, 0x660B)
#define PR_OTLKCON_ACCOUNT_DEFAULT_2        PROP_TAG(PT_BOOLEAN, 0x660C)
#define PR_OTLKCON_ACCOUNT_ENABLE_2         PROP_TAG(PT_BOOLEAN, 0x660D)

//Account 3
#define PR_OTLKCON_ACCOUNT_ID_3             PROP_TAG(PT_STRING8, 0x660E)
#define PR_OTLKCON_ACCOUNT_TYPE_3           PROP_TAG(PT_LONG,    0x660F)
#define PR_OTLKCON_ACCOUNT_NAME_3           PROP_TAG(PT_STRING8, 0x6610)
#define PR_OTLKCON_ACCOUNT_DEFAULT_3        PROP_TAG(PT_BOOLEAN, 0x6611)
#define PR_OTLKCON_ACCOUNT_ENABLE_3         PROP_TAG(PT_BOOLEAN, 0x6612)

//Account 4
#define PR_OTLKCON_ACCOUNT_ID_4             PROP_TAG(PT_STRING8, 0x6613)
#define PR_OTLKCON_ACCOUNT_TYPE_4           PROP_TAG(PT_LONG,    0x6614)
#define PR_OTLKCON_ACCOUNT_NAME_4           PROP_TAG(PT_STRING8, 0x6615)
#define PR_OTLKCON_ACCOUNT_DEFAULT_4        PROP_TAG(PT_BOOLEAN, 0x6616)
#define PR_OTLKCON_ACCOUNT_ENABLE_4         PROP_TAG(PT_BOOLEAN, 0x6617)

//Set to 'true' if the address book provider is allowed to run against this
//message store object.
#define PR_OTLKCON_AB_ENABLED               PROP_TAG(PT_BOOLEAN, 0x6618)

// FIXME: This really should be a multi-valued property.
// Property for mapping MAPI objects to remote objects
#define PR_OTLKCON_FOREIGN_ID               PROP_TAG(PT_STRING8, 0x6619)

// TODO: Should hash be binary?
#define PR_OTLKCON_FOREIGN_HASH             PROP_TAG(PT_STRING8, 0x661A)

// Default appointment folder
#define PR_OTLKCON_FOLDER_APPMT_DEFAULT     PROP_TAG(PT_BOOLEAN, 0x661B)

// Should we use the stored master password?
#define PR_OTLKCON_USE_MASTER_PASSWORD      PROP_TAG(PT_BOOLEAN, 0x6618)

// Should this object be uploaded?
#define PR_OTLKCON_UPLOAD                   PROP_TAG(PT_BOOLEAN, 0x661C)
#define PR_OTLKCON_DOWNLOAD                 PROP_TAG(PT_BOOLEAN, 0x661D)

// A bitmask of pending actions on an object
#define PR_OTLKCON_PENDING_ACTIONS          PROP_TAG(PT_LONG, 0x661E)

#define PR_OTLKCON_ACCOUNT_AB_ENABLE_1      PROP_TAG(PT_BOOLEAN, 0x661F)
#define PR_OTLKCON_ACCOUNT_AB_ENABLE_2      PROP_TAG(PT_BOOLEAN, 0x6620)
#define PR_OTLKCON_ACCOUNT_AB_ENABLE_3      PROP_TAG(PT_BOOLEAN, 0x6621)
#define PR_OTLKCON_ACCOUNT_AB_ENABLE_4      PROP_TAG(PT_BOOLEAN, 0x6622)

// FIXME: Shouldn't these be secure?
#define PR_OTLKCON_ACCOUNT_PRINCIPLE_URI_1  PROP_TAG(PT_STRING8, 0x6623)
#define PR_OTLKCON_ACCOUNT_PRINCIPLE_URI_2  PROP_TAG(PT_STRING8, 0x6624)
#define PR_OTLKCON_ACCOUNT_PRINCIPLE_URI_3  PROP_TAG(PT_STRING8, 0x6625)
#define PR_OTLKCON_ACCOUNT_PRINCIPLE_URI_4  PROP_TAG(PT_STRING8, 0x6626)

// A private EntryID for Open Connector.  This is used for object which
// do not typically store the PR_ENTRYID property but we would like to
// keep an EntryID for them.
#define PR_OTLKCON_ENTRYID                  PROP_TAG(PT_BINARY, 0x6627)

//// Secure properties 0x67F0 to 0x67FF

//Account 1
#define PR_OTLKCON_ACCOUNT_USERNAME_1       PROP_TAG(PT_STRING8, 0x67F0)
#define PR_OTLKCON_ACCOUNT_PASSWORD_1       PROP_TAG(PT_STRING8, 0x67F1)
#define PR_OTLKCON_ACCOUNT_URI_1            PROP_TAG(PT_STRING8, 0x67F2)

//Account 2
#define PR_OTLKCON_ACCOUNT_USERNAME_2       PROP_TAG(PT_STRING8, 0x67F3)
#define PR_OTLKCON_ACCOUNT_PASSWORD_2       PROP_TAG(PT_STRING8, 0x67F4)
#define PR_OTLKCON_ACCOUNT_URI_2            PROP_TAG(PT_STRING8, 0x67F5)

//Account 3
#define PR_OTLKCON_ACCOUNT_USERNAME_3       PROP_TAG(PT_STRING8, 0x67F6)
#define PR_OTLKCON_ACCOUNT_PASSWORD_3       PROP_TAG(PT_STRING8, 0x67F7)
#define PR_OTLKCON_ACCOUNT_URI_3            PROP_TAG(PT_STRING8, 0x67F8)

//Account 4
#define PR_OTLKCON_ACCOUNT_USERNAME_4       PROP_TAG(PT_STRING8, 0x67F9)
#define PR_OTLKCON_ACCOUNT_PASSWORD_4       PROP_TAG(PT_STRING8, 0x67FA)
#define PR_OTLKCON_ACCOUNT_URI_4            PROP_TAG(PT_STRING8, 0x67FB)

//Master password : Should deter the user from storing this.
#define PR_OTLKCON_PASSWORD                 PROP_TAG(PT_STRING8, 0x67FC)

//// Named Properties
#define OTLKCON_RECEIVEFOLDERTABLE_NAME     L"receiveFolderTable"
#define OTLKCON_OUTGOINGQUEUE_NAME          L"outgoingQueueTable"

//// END PROPERTIES



// The last thing we do is include a local config header
// Make modifications in that file
#include <otlkcon_local_config.h>
